import { AdManager, ReportType } from "../ads/AdManager";
import { EventManager } from "../manager/EventManager";
import { UIManager } from "../manager/UIManager";
import { BUNDLE_TYPE_ENUM, EVENT_NAME_ENUM } from "../base/EnumIndex";
import { LevelManager } from "../manager/LevelManager";
import { AudioManager1 } from "../manager/AudioManager1";

const { ccclass, property } = cc._decorator;

/** 加步数弹窗 */
@ccclass
export default class StepUI extends cc.Component {
    @property(cc.Label)
    numLbl: cc.Label = null;

    onLoad() {
    }
    start() {
        // this.numLbl.string = "60s"
        AdManager.naoLiReportVideo(1, "增加步数");
    }

    /** 返回主页 */
    returnMain() {
        // UIManager.ins.showPop("OverUI", BUNDLE_TYPE_ENUM.GAME);
        UIManager.ins.showUI("LevelUI", BUNDLE_TYPE_ENUM.HOME)
    }

    clickBtnReturn() {
        AudioManager1.playClick();
        UIManager.ins.closeAll();
        // this.returnMain();
        LevelManager.ins.loadLevelPre();
        // this.runNodeTween(this.viewBg, this.getInterTwForName("overGame").interTween);
    }

    clickBtnAddStep() {
        AudioManager1.playClick();
        let idx = LevelManager.ins.getLvInfoIdx(LevelManager.ins.curLvInfo.type, LevelManager.ins.curLvInfo.lv) + 1;
        AdManager.reportVideo(6, idx, LevelManager.ins.curLvInfo.name);
        AdManager.naoLiReportVideo(2, "增加步数");
        AdManager.umengEvent(ReportType.CLICK_ADS, { tag: "广告开始", name: LevelManager.ins.curLvInfo.name, value: "增加步数" });
        AdManager.showVideoAd(() => {
            AdManager.reportOverVideo(idx, LevelManager.ins.curLvInfo.name);
            UIManager.ins.close();
            AdManager.umengEvent(ReportType.CLICK_ADS, { tag: "广告完成", name: LevelManager.ins.curLvInfo.name, value: "增加步数" });
            EventManager.ins.emit(EVENT_NAME_ENUM.ADD_STEP);
            AdManager.naoLiReportVideo(3, "增加步数");
            AdManager.naoLiReportVideo(4, "增加步数");

        });
    }
}
